;;; packages - package definitions for GNU Guix
;;; Copyright (C) 2017 ng0
;;;
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU Affero General Public License as
;;; published by the Free Software Foundation, either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU Affero General Public License for more details.
;;;
;;; You should have received a copy of the GNU Affero General Public License
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

(define-module (ng0 packages package-management)
  #:use-module (guix packages)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix download)
  #:use-module (guix gexp)
  #:use-module (guix utils)
  #:use-module (guix git-download)
  #:use-module (gnu packages)
  #:use-module (guix build-system gnu)
  #:use-module (ice-9 match)
  #:use-module (gnu packages package-management))

(define-public guix-docs
  (package
    (inherit current-guix)
    (name "guix-docs")
    ;; FIXME: Actually inherit in a smart way and do not override the arguments.
    (arguments
     `(#:configure-flags (list "--localstatedir=/var"
                               "--sysconfdir=/etc"
                               (string-append "--with-bash-completion-dir="
                                              (assoc-ref %outputs "out")
                                              "/etc/bash_completion.d")
                               (string-append "--with-libgcrypt-prefix="
                                              (assoc-ref %build-inputs
                                                         "libgcrypt")))
       #:parallel-tests? #f           ;work around <http://bugs.gnu.org/21097>
       #:tests? #f
       #:modules ((guix build gnu-build-system)
                  (guix build utils)
                  (ice-9 popen)
                  (ice-9 rdelim))
                               
       #:phases
       (modify-phases %standard-phases
         (replace 'build
           (lambda _
             (zero? (system* "make" "doc/guix.html"))))
         (replace 'install
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
                    (html (string-append out "/srv/html")))
               (mkdir-p html)
               (copy-file-recursively "doc/guix.html" html)
               #t))))))))
